package com.yunhe.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.SqlSession;

import com.yunhe.bean.UserTier;
import com.yunhe.inter.UserDao;
import com.yunhe.util.SqlSessionFactoryUtil;

/**
 * Servlet implementation class regserlvet1
 */
@WebServlet("/regserlvet1")
public class regserlvet1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
	SqlSession sqlSession;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public regserlvet1() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("text/html");
		request.setCharacterEncoding("UTF-8");
		 String userName=request.getParameter("userName");
		 sqlSession =  SqlSessionFactoryUtil.openSqlSession();
		 PrintWriter pw=response.getWriter();
		 UserDao mapper = sqlSession.getMapper(UserDao.class);
	     UserTier ut1 = mapper.RegUser(userName);
	        if(ut1==null){
				pw.print(false);
			}else{
				pw.print(true);				
			}
	        pw.flush();
	        pw.close();
	   
  
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
